﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZedGraph;

namespace TSTreeThesis.UI
{
    public partial class QueryResultForm : Form
    {
        private MainForm frmMain;
        public QueryResultForm(MainForm frmMain)
        {
            InitializeComponent();
            this.frmMain = frmMain;
        }

        public void SetData(PointPairList queryList, PointPairList resultList, int index, double distance)
        {
            zedGraph.GraphPane.CurveList.Clear();

            addLine(zedGraph, "Retrieval object", resultList, Color.Blue, SymbolType.None, 2, "");
            addLine(zedGraph, "Query object", queryList, Color.Red, SymbolType.None, 2, String.Format("Index = {0}, Distance = {1}", index, distance));
        }

        private void addLine(ZedGraphControl zgc, string name, PointPairList dataList, Color color, SymbolType s, int width, string filename)
        {
            GraphPane myPane = zgc.GraphPane;
            LineItem myCurve = myPane.AddCurve(name, dataList, color, s);
            myCurve.Line.Width = width;
            myPane.Title.Text = filename;
            myPane.XAxis.Title.Text = "Times";
            myPane.YAxis.Title.Text = "Values";
            zgc.AxisChange();
            zgc.Refresh();
        }

        private void QueryResultForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmMain.SetNullResultFrm();
        }
    }
}
